/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package gui.handlers;

import java.io.IOException;
import javax.swing.text.BadLocationException;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;

/**
 *
 * @author mazzahaka
 */
public class LogHandler{
  private static  HTMLEditorKit kit = new HTMLEditorKit();
  private static  HTMLDocument  doc = new HTMLDocument();
  public LogHandler(){
        gui.gui.Log.setEditorKit(kit);
        gui.gui.Log.setDocument(doc);
        info("LogHandler Daemon loaded!");
   }
    public static void  err(String err){AddToLog("<font color='red'><b>[ERROR]</b>"+err+"</font>");}
    public static void  info(String info){AddToLog("<b>[INFO]</b>"+info);}
    public static void  warn(String warn){AddToLog("<font color='#FFA500'><b>[WARN]</b>"+warn+"</font>");};
    private static void  AddToLog(String Content) {
        try {
            LogHandler.kit.insertHTML(LogHandler.doc, LogHandler.doc.getLength(), Content, 0, 0, null);
        } catch (BadLocationException ex) {
            System.out.print("[ERROR]Failed add to log!");
        } catch (IOException ex) {
              System.out.print("[ERROR]Failed add to log!");
        }
        gui.gui.Log.setDocument(LogHandler.doc);
    }
}
